<?php
/**
 * Created by openXtiger.org.
 * User: xtiger
 * Date: 2009-5-11
 * Time: 16:08:21
 */


define('IN_XCENTERAPI', 'TRUE');

define('XC_SERVER_VERSION', '1.0.0');
define('XC_SERVER_RELEASE', '20090624');
error_reporting(1);
set_magic_quotes_runtime(0);

include './xcapi.server.php';

$_GET = xc_daddslashes($_GET, 1, TRUE);


$m = xc_pget('m');
$a = xc_pget('a');
if(empty($m) && empty($a)) {
	header('Location: ../index.php');
	exit;
}
$_xcapi_appid = xc_pget('appid');
$release = xc_pget('release');
if(in_array($m, array('user'))) {
    $input = xc_pget('input');
    if($input && ($app=$_xcapi_config[$_xcapi_appid])) {
        $input = xc_authcode($input, 'DECODE', $app['authkey']);
        $inputs = array();
        parse_str($input, $inputs);
        $inputs = xc_daddslashes($inputs, 1, TRUE);
        $getagent = '';
        $agent = $getagent ? $getagent : $inputs['agent'];
        if(($getagent && $getagent != $agent) || (!$getagent && md5($_SERVER['HTTP_USER_AGENT']) != $agent)) {
            exit('Access denied for agent changed');
        } elseif(time() - $inputs['time'] > 3600) {
            exit('Authorization has expired');
        }
        xcapi_mysql_callback($m,$a,$inputs);
        exit;

    } else{
        exit('Invalid input');
    }

}



?>